home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tclX6.4c / dist / tclsrc / stringfile.tcl < prev   
Encoding:
Text File  |  1992-11-07  |  1.2 KB  |  40 lines

  1. #
  2. # string_file --
  3. #
  4. # Functions to read and write strings from a file that has not been opened.
  5. #------------------------------------------------------------------------------
  6. # Copyright 1992 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: stringfile.tcl,v 2.0 1992/10/16 04:52:13 markd Rel $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. #@package: TclX-stringfile_functions read_file write_file
  20.  
  21. proc read_file {fileName {numBytes {}}} {
  22.     set fp [open $fileName]
  23.     if {$numBytes != ""} {
  24.         set result [read $fp $numBytes]
  25.     } else {
  26.         set result [read $fp]
  27.     }
  28.     close $fp
  29.     return $result
  30.  
  31. proc write_file {fileName args} {
  32.     set fp [open $fileName w]
  33.     foreach string $args {
  34.         puts $fp $string
  35.     }
  36.     close $fp
  37. }
  38.  
  39.